package com.cskaoyan.controller;

import com.cskaoyan.bean.baseresultVO.BaseRespVo;
import com.cskaoyan.bean.config.ExpressConfig;
import com.cskaoyan.bean.config.MallConfig;
import com.cskaoyan.bean.config.OrderConfig;
import com.cskaoyan.bean.config.WxConfig;
import com.cskaoyan.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description:
 * @author:
 * @date:
 */
@RestController
@RequestMapping("/admin/config")
public class ConfigController {
    @Autowired
    ConfigService configService;

    @GetMapping("mall")
    public BaseRespVo<MallConfig> getMall() {
        MallConfig mallConfig = configService.mall();
        return BaseRespVo.ok(mallConfig);
    }

    @PostMapping("mall")
    public BaseRespVo<MallConfig> postMall(@RequestBody MallConfig mallConfig) {
        MallConfig mallUpdate = configService.mallUpdate(mallConfig);
        return BaseRespVo.ok(null);
    }

    @GetMapping("express")
    public BaseRespVo<ExpressConfig> getExpress() {
        ExpressConfig expressConfig = configService.express();
        return BaseRespVo.ok(expressConfig);
    }

    @PostMapping("express")
    public BaseRespVo<ExpressConfig> postExpress(@RequestBody ExpressConfig expressConfig) {
        ExpressConfig expressUpdate = configService.expressUpdate(expressConfig);
        return BaseRespVo.ok(null);
    }

    @GetMapping("order")
    public BaseRespVo<ExpressConfig> getOrder() {
        OrderConfig orderConfig = configService.order();
        return BaseRespVo.ok(orderConfig);
    }

    @PostMapping("order")
    public BaseRespVo<OrderConfig> postOrder(@RequestBody OrderConfig orderConfig) {
        OrderConfig orderUpdate = configService.orderUpdate(orderConfig);
        return BaseRespVo.ok(null);
    }

    @GetMapping("wx")
    public BaseRespVo<ExpressConfig> getWx() {
        WxConfig wxConfig = configService.wx();
        return BaseRespVo.ok(wxConfig);
    }

    @PostMapping("wx")
    public BaseRespVo<WxConfig> postWx(@RequestBody WxConfig wxConfig) {
        WxConfig wxUpdate = configService.wxUpdate(wxConfig);
        return BaseRespVo.ok(null);
    }


}
